home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / ULARN.ARJ / ULARN.TAR / ularn / bill.c next >
C/C++ Source or Header  |  1989-10-25  |  6KB  |  192 lines

  1. /* bill.c         */
  2.  
  3. #include "header.h"
  4.  
  5. static char mail600[32];
  6. /*
  7.  *    function to create the tax bill for the user
  8.  */
  9. static int pid;
  10. letter1()
  11. {
  12.     sprintf(mail600, "/tmp/#%dmail600",pid); /* prepare path */
  13.     if (lcreat(mail600) < 0) { 
  14.         write(1,"can't write 600 letter\n",23); 
  15.         return(0);
  16.     }
  17. lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
  18. lprcat("From:"); 
  19. lprcat("  the URS (Ularn Revenue Service)\n");
  20. lprcat("\nSubject:"); 
  21. lprcat("  undeclared income\n");
  22. lprcat("\n   We heard you survived the caverns of Ularn.  Let me be the");
  23. lprcat("\nfirst to congratulate you on your success.  It is quite a feat.");
  24. lprcat("\nIt must also have been very profitable for you.");
  25. lprcat("\n\n   The Dungeon Master has informed us that you brought");
  26. lprintf("\n%d gold pieces back with you from your journey.  As the",
  27.     (long)c[GOLD]);
  28. lprcat("\ncounty of Ularn is in dire need of funds, we have spared no time");
  29. lprintf("\nin preparing your tax bill.  You owe %d gold pieces as",
  30.     (long)c[GOLD]*TAXRATE);
  31. lprcat("\nof this notice, and is due within 5 days.  Failure to pay will");
  32. lprcat("\nmean penalties.  Once again, congratulations, We look forward");
  33. lprcat("\nto your future successful expeditions.\n");
  34.     lwclose(); 
  35.     return(1);
  36. }
  37.  
  38. letter2()
  39. {
  40.     sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
  41.     if (lcreat(mail600) < 0) { 
  42.         write(1,"can't write 601 letter\n",23); 
  43.         return(0);
  44.     }
  45. lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
  46. lprcat("From:"); 
  47. lprcat("  His Majesty King Wilfred of Ularndom\n");
  48. lprcat("\nSubject:"); 
  49. lprcat("  a noble deed\n");
  50. lprcat("\n   I have heard of your magnificent feat, and I, King Wilfred,");
  51. lprcat("\nforthwith declare today to be a national holiday.  Furthermore,");
  52. lprcat("\nhence three days, Ye be invited to the castle to receive the");
  53. if (sex)
  54. lprcat("\nhonour of Knight of the realm.  Upon thy name shall it be written. . .");
  55. else
  56. lprcat("\nhonour of Knightess of the realm.  Upon thy name shall it be written. . .");
  57. lprcat("\nBravery and courage be yours.");
  58. lprcat("\nMay you live in happiness forevermore . . .\n");
  59. lwclose(); 
  60. return(1);
  61. }
  62.  
  63. letter3()
  64. {
  65.     sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
  66.     if (lcreat(mail600) < 0) { 
  67.         write(1,"can't write 602 letter\n",23); 
  68.         return(0);
  69.     }
  70.     lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
  71.     lprcat("From:"); 
  72.     lprcat("  Count Endelford\n");
  73.     lprcat("\nSubject:"); 
  74.     if (sex)
  75.         lprcat("  You Bastard!\n");
  76.     else
  77.         lprcat("  You Bitch!\n");
  78. lprcat("\n   I heard (from sources) of your journey.  Congratulations!");
  79.     if (sex)
  80.         lprcat("\nYou Bastard!  ");
  81.     else
  82.         lprcat("\nYou Bitch!  ");
  83. lprcat("With several attempts I have yet to endure the");
  84. lprcat(" caves,\nand you, a nobody, makes the journey!  From this time");
  85. lprcat(" onward, bewarned\nupon our meeting you shall pay the price!\n");
  86.     lwclose(); 
  87.     return(1);
  88. }
  89.  
  90. letter4()
  91. {
  92.     sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
  93.     if (lcreat(mail600) < 0) { 
  94.         write(1,"can't write 603 letter\n",23); 
  95.         return(0);
  96.     }
  97.     lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
  98.     lprcat("From:"); 
  99.     lprcat("  Mainair, Duke of Ularnty\n");
  100.     lprcat("\nSubject:"); 
  101.     lprcat("  High Praise\n");
  102. lprcat("\n   With a certainty a hero I declare to be amongst us!  A nod of");
  103. lprcat("\nfavour I send to thee.  Me thinks Count Endelford this day of");
  104. lprcat("\nright breath'eth fire as of dragon of whom ye are slayer.  I");
  105. lprcat("\nyearn to behold his anger and jealously.  Should ye choose to");
  106. lprcat("\nunleash some of thy wealth upon those who be unfortunate, I,");
  107.     lprcat("\nDuke Mainair, Shall equal thy gift also.\n");
  108.     lwclose(); 
  109.     return(1);
  110. }
  111.  
  112. letter5()
  113. {
  114.     sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
  115.     if (lcreat(mail600) < 0) { 
  116.         write(1,"can't write 604 letter\n",23); 
  117.         return(0);
  118.     }
  119.     lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
  120.     lprcat("From:"); 
  121.     lprcat("  St. Mary's Children's Home\n");
  122.     lprcat("\nSubject:"); 
  123.     lprcat("  these poor children\n");
  124. lprcat("\n   News of your great conquests has spread to all of Ularndom.");
  125. lprcat("\nMight I have a moment of a great ");
  126.     if (!sex)
  127.         lprcat("woman's");
  128.     else
  129.         lprcat("man's");
  130. lprcat(" time.  We here at St.");
  131.     lprcat("\nMary's Children's Home are very poor, and many children are");
  132. lprcat("\nstarving.  Disease is widespread and very often fatal without");
  133. lprcat("\ngood food.  Could you possibly find it in your heart to help us");
  134.     lprcat("\nin our plight?  Whatever you could give will help much.");
  135.     lprcat("\n(your gift is tax deductible)\n");
  136.     lwclose(); 
  137.     return(1);
  138. }
  139.  
  140. letter6()
  141. {
  142.     sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
  143.     if (lcreat(mail600) < 0) { 
  144.         write(1,"can't write 605 letter\n",23); 
  145.         return(0);
  146.     }
  147.     lprcat("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
  148.     lprcat("From:"); 
  149.     lprcat("  The National Dianthroritis Society of Ularn\n");
  150.     lprcat("\nSubject:"); 
  151.     lprcat("  hope\n");
  152. lprcat("\nCongratulations on your successful expedition.  We are sure much");
  153. lprcat("\ncourage and determination were needed on your quest.  There are");
  154. lprcat("\nmany though, that could never hope to undertake such a journey");
  155. lprcat("\ndue to an enfeebling disease -- dianthroritis.  We at the National");
  156. lprcat("\nDianthroritis Society of Ularn wish to appeal to your philanthropy in");
  157. lprcat("\norder to save many good people -- possibly even yourself or a loved one a few");
  158. lprcat("\nyears from now.  Much work needs to be done in researching this");
  159. lprcat("\ndreaded disease, and you can help today.  Could you please see it");
  160. lprcat("\nin your heart to give generously?  Your continued good health");
  161.     lprcat("\ncan be your everlasting reward.\n");
  162.     lwclose(); 
  163.     return(1);
  164. }
  165.  
  166. /*
  167.  *    function to mail the letters to the player if a winner
  168.  */
  169. static int (*pfn[])()= { 
  170.     letter1, letter2, letter3, letter4, letter5, letter6 
  171. };
  172.  
  173. mailbill()
  174. {
  175.     register int i;
  176.     char buf[128];
  177.  
  178.     wait(0);  
  179.     pid=getpid();
  180.     if (fork() == 0) {
  181.         resetscroll();
  182.         for (i=0; i<sizeof(pfn)/sizeof(int (*)()); i++)
  183.             if ((*pfn[i])()) {
  184.                 sleep(20);  
  185.                 sprintf(buf,"mail %s < %s",loginname,mail600);
  186.                 system(buf);  
  187.                 unlink(mail600);
  188.             }
  189.         exit(0);
  190.     }
  191. }
  192.